// pages/pay/paidOrder/paidDetail/paidDetail.js
var api = require("../../../api.js"),
    app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        order: null,
        reduce: null,
        total: null,
        order_no: '',
        pay:false,
    },
    driverToHome(){
      wx.navigateTo({
        url:'/pages/map/driverServer/driverServer'
      })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.setData({
            order_no: options.order_no,
            
        })
      // 获取优惠券
      if (options.uid) {
        app.shareCouponsMessage(options.uid)
      }
    },
    //进入计价规则
    intoRule: function (e) {
      wx.navigateTo({
        url: e.currentTarget.dataset.url,
      })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        var that = this;
        app.request({
            url: api.order.order_cost,
            method: 'post',
            data: {
                order_no: that.data.order_no,
            },
            success: function(rs) {
              console.log(111)
              console.log(rs)
                if (rs.code == 1) {
                    that.setData({
                        order: rs.data,
                    })
                }
            }
        })
    },
  // 用户分享
  onShareAppMessage: function () {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    // console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
  driverGood(){
    wx.navigateTo({
      url:"/pages/user/evaluate/evaluate?order_no=" + this.data.order_no
    })
  },
  order_del(){
    const order_no = this.data.order_no
    app.request({
      url:api.order.order_del,
      method:'post',
      data:{
        order_no
      },
      success(res){
        console.log('yjy')
        console.log(res)
        if(res.code===1){
          wx.showToast({
            title:res.msg
          })
          setTimeout(()=>{
            wx.navigateTo({
              url:'/pages/userOrder/allOrder/allOrder'
            })  
          },1000)
        }
      }
    })
  },
})